package com.newlink.building.userinfo.mvp.model

import com.newlink.building.common_base.base.BaseModel
import com.newlink.building.common_base.http.Base_RetrofitHelper
import com.newlink.building.common_base.model.bean.DeviceListData
import com.newlink.building.common_base.model.bean.DeviceListRequest
import com.newlink.building.common_base.model.bean.HttpResult
import com.newlink.building.common_base.model.bean.KitDeviceData
import com.newlink.building.common_base.model.bean.KitDeviceEditData
import com.newlink.building.common_base.model.bean.StatusData
import com.newlink.building.userinfo.mvp.contract.Module_UserInfo_DeviceSettingContract
import io.reactivex.Observable

class Module_UserInfo_DeviceSettingModel : BaseModel(), Module_UserInfo_DeviceSettingContract.Model {

    override fun getDeviceList(request: DeviceListRequest): Observable<HttpResult<DeviceListData>> {
        return Base_RetrofitHelper.service.getDeviceList(
            request.accessToken,
            request.page,
            request.limit,
            request.devName,
            request.devType
        )
    }

    override fun editKitDevice(
        token: String,
        deviceData: KitDeviceData
    ): Observable<HttpResult<StatusData>> {
        return Base_RetrofitHelper.service.editDevice(
            token,
            KitDeviceEditData(deviceData.name, deviceData.mac, deviceData.type, deviceData.doors)
        )
    }

    override fun addKitDevice(
        token: String,
        deviceData: KitDeviceData
    ): Observable<HttpResult<StatusData>> {
        return Base_RetrofitHelper.service.addKitDevice(token, deviceData)
    }

    override fun deleteKitDevice(token: String, mac: String): Observable<HttpResult<StatusData>> {
        return Base_RetrofitHelper.service.deleteKitDevice(token, mac)
    }
}